package com.gitee.wsl.mathematics.matrix.mat2.ext

import com.gitee.wsl.mathematics.matrix.mat2.Matrix2
import com.gitee.wsl.mathematics.vector.vec2.MutableVector2
import com.gitee.wsl.mathematics.vector.vec2.Vector2


fun <T:Number> Matrix2<T, *, *>.transform(vec: MutableVector2<T, *>) {
    vec.x = vec.x * this[0, 0] + vec.y * this[0, 1]
    vec.y = vec.x * this[1, 0] + vec.y * this[1, 1]
}

fun <T:Number,V: Vector2<T, V>> MutableVector2<T, V>.transform(mat2: Matrix2<T, *, *>) = mat2.transform(this)


fun <T:Number,V: Vector2<T, V>> Vector2<T, V>.transform(mat2: Matrix2<*, *, *>):V {
    val retx = x * mat2[0, 0] + y * mat2[0, 1]
    val rety = x * mat2[1, 0] + y * mat2[1, 1]
    return create(retx,rety)
}